package com.trade.module.base.entity;

import com.trade.common.utils.Constants;
import com.trade.common.utils.IdGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Class Description:系统日志实体类
 *
 * @Version v1.0 2017/4/21 20:28
 * @JDK version 1.8.0_51
 * @Author zfb
 */
@Entity
@Table(name = "base_systemlog")
public class SystemLog implements Serializable{
    private static final long serialVersionUID = 2902425604665165136L;

    /** Field description：主键标识 */
    @Id
    @Column(
            name       = "id",
            unique     = true,
            nullable   = false,
            insertable = true,
            length     = 64
    )
    private String id;

    /*Field description：日志级别*/
    @Column(
            name = "logLevel",
            nullable = false,
            length = 10
    )
    private String logLevel;

    /*Field description：日志所属功能模块*/
    @Column(
            name = "logModel",
            nullable = false,
            length = 64
    )
    private String logModel;

    /*Field description： 操作类型*/
    @Column(
            name = "operatType",
            nullable = false,
            length = 10
    )
    private String operatType;

    /*Field description：操作结果*/
    @Column(
            name = "operatResult",
            nullable = false,
            length = 10
    )
    private String operatResult;

    /**Field description：操作人id**/
    @Column(
            name = "operatUserId",
            nullable = false,
            length = 64
    )
    private String operatUserId;

    /**Field description：操作人id**/
    @Column(
            name = "operat_user_account",
            nullable = false,
            length = 32
    )
    private String operatUserAccount;

    /*Field description：操作描述*/
    @Column(
            name = "operatDesc",
            nullable = false,
            length = 128
    )
    private String operatDesc;
    /*Field description：被操作对象id*/
    @Column(
            name = "entityId",
            nullable = false,
            length =64
    )
    private String entityId;
    /*Field description：操作ip*/
    @Column(
            name = "ipAddress",
            nullable = false,
            length = 32
    )
    private String ipAddress;

    /** Field description：数据状态（1：正常；2：删除；0：状态无效） */
    @Column(
            name   = "data_flag",
            length = 5
    )
    private String dataFlag;

    /** Field description ：创建时间 */
    @Column(
            name     = "create_time",
            nullable = false,
            columnDefinition="Timestamp"
    )
    private Date createTime;

    /**
     * Method description：数据插入前的操作
     * Version:V1.0
     * Author:Shaok Lei
     * Date:2016.02.26 at 05:37:57 CST
     */
    @PrePersist
    public void setInsertBefore() {
        // 插入数据前设置ID和创建时间
        this.setId(IdGenerator.createNewId());
        this.setDataFlag(Constants.DATA_FLAG_OK);
        this.setCreateTime(new Date());
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLogLevel() {
        return logLevel;
    }

    public void setLogLevel(String logLevel) {
        this.logLevel = logLevel;
    }

    public String getLogModel() {
        return logModel;
    }

    public void setLogModel(String logModel) {
        this.logModel = logModel;
    }

    public String getOperatType() {
        return operatType;
    }

    public void setOperatType(String operatType) {
        this.operatType = operatType;
    }

    public String getOperatResult() {
        return operatResult;
    }

    public void setOperatResult(String operatResult) {
        this.operatResult = operatResult;
    }

    public String getOperatUserId() {
        return operatUserId;
    }

    public void setOperatUserId(String operatUserId) {
        this.operatUserId = operatUserId;
    }

    public String getOperatUserAccount() {
        return operatUserAccount;
    }

    public void setOperatUserAccount(String operatUserAccount) {
        this.operatUserAccount = operatUserAccount;
    }

    public String getOperatDesc() {
        return operatDesc;
    }

    public void setOperatDesc(String operatDesc) {
        this.operatDesc = operatDesc;
    }

    public String getEntityId() {
        return entityId;
    }

    public void setEntityId(String entityId) {
        this.entityId = entityId;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public String getDataFlag() {
        return dataFlag;
    }

    public void setDataFlag(String dataFlag) {
        this.dataFlag = dataFlag;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
